Fix RailsPulse middleware crash on blank request paths#132
Closed
Fix RailsPulse middleware crash on blank request paths#132
Conversation
Co-authored-by: 24c02 <163450896+24c02@users.noreply.github.com>
Co-authored-by: 24c02 <163450896+24c02@users.noreply.github.com>
Co-authored-by: 24c02 <163450896+24c02@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix ActiveRecord validation error for route
Fix RailsPulse middleware crash on blank request paths
Dec 23, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Production error:
ActiveRecord::RecordInvalid: Validation failed: Route can't be blankoccurs when RailsPulse middleware encounters requests with blank paths or methods (malformed requests, edge cases).Root Cause
RailsPulse::Middleware::RequestCollector#find_or_create_routecallsfind_or_create_by(method:, path:)without validating inputs. TheRoutemodel requires both fields present, raising an exception that crashes the middleware chain.Changes
Monkey-patch
find_or_create_routeinconfig/initializers/rails_pulse_fixes.rbto:nilfor blank path/method before database operationsActiveRecord::RecordInvalidto prevent middleware crashesThe existing middleware already handles
nilroutes gracefully via theif routeguard at line 46 inrequest_collector.rb.Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.